package com.ruoyi.web.controller.system;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.FaEsmOrderinfo;
import com.ruoyi.system.service.IFaEsmOrderinfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 每日制令单Controller
 * 
 * @author colin
 * @date 2021-09-16
 */
@RestController
@RequestMapping("/system/orderinfo")
public class FaEsmOrderinfoController extends BaseController
{
    @Autowired
    private IFaEsmOrderinfoService faEsmOrderinfoService;

    /**
     * 查询每日制令单列表
     */
    @PreAuthorize("@ss.hasPermi('system:orderinfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(FaEsmOrderinfo faEsmOrderinfo)
    {
        startPage();
        List<FaEsmOrderinfo> list = faEsmOrderinfoService.selectFaEsmOrderinfoList(faEsmOrderinfo);
        return getDataTable(list);
    }

    /**
     * 导出每日制令单列表
     */
    @PreAuthorize("@ss.hasPermi('system:orderinfo:export')")
    @Log(title = "每日制令单", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FaEsmOrderinfo faEsmOrderinfo)
    {
        List<FaEsmOrderinfo> list = faEsmOrderinfoService.selectFaEsmOrderinfoList(faEsmOrderinfo);
        ExcelUtil<FaEsmOrderinfo> util = new ExcelUtil<FaEsmOrderinfo>(FaEsmOrderinfo.class);
        return util.exportExcel(list, "每日制令单数据");
    }

    /**
     * 获取每日制令单详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:orderinfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(faEsmOrderinfoService.selectFaEsmOrderinfoById(id));
    }

    /**
     * 新增每日制令单
     */
    @PreAuthorize("@ss.hasPermi('system:orderinfo:add')")
    @Log(title = "每日制令单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FaEsmOrderinfo faEsmOrderinfo)
    {
        return toAjax(faEsmOrderinfoService.insertFaEsmOrderinfo(faEsmOrderinfo));
    }

    /**
     * 修改每日制令单
     */
    @PreAuthorize("@ss.hasPermi('system:orderinfo:edit')")
    @Log(title = "每日制令单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FaEsmOrderinfo faEsmOrderinfo)
    {
        return toAjax(faEsmOrderinfoService.updateFaEsmOrderinfo(faEsmOrderinfo));
    }

    /**
     * 删除每日制令单
     */
    @PreAuthorize("@ss.hasPermi('system:orderinfo:remove')")
    @Log(title = "每日制令单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(faEsmOrderinfoService.deleteFaEsmOrderinfoByIds(ids));
    }
}
